package com.xtr.service;


import com.lcn.comm.annotation.TxTransaction;
import com.weibo.api.motan.config.springsupport.annotation.MotanReferer;
import com.xtr.tx.domain.SysTest;
import com.xtr.tx.service.SysDemoService;
import com.xtr.tx.service.SysExampleService;
import com.xtr.tx.service.SysTestService;
import com.xtr.tx.writer.SysTestWriterMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>类说明</p>
 *
 * @author 张峰 zfvip_it@163.com
 * @createTime: 2017/11/13 12:59
 */
@Service
public class SysTestServiceImpl implements SysTestService {


    @Resource
    private SysTestWriterMapper sysTestWriterMapper;

    @MotanReferer()
    private SysDemoService sysDemoService;

    @MotanReferer
    private SysExampleService sysExampleService;


    public void save() {
        SysTest sysTest = new SysTest();
        sysTest.setName("测试1");
        sysTestWriterMapper.insertSelective(sysTest);
    }

    @TxTransaction
    @Transactional
    public void test() {
        save();
        save();
        save();
        sysDemoService.save();
        sysExampleService.save();
//        sysDemoService.readerQueryAll();
//        sysDemoService.writerQueryAll();
//        sysExampleService.update();
//        sysExampleService.update();
    }

    @TxTransaction
    @Transactional
    public void test1() {
        save();
        sysDemoService.save();
        sysDemoService.save();
        sysDemoService.save();
        sysDemoService.save();
        sysDemoService.save();
//        sysExampleService.update();
        sysExampleService.save();
//        sysExampleService.update1();
        sysExampleService.save1();
    }
}
